%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Illustrate implications of counter-factuals for prime-age female
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

l_0=100*mean(Lr{1}(:,2:4),2);
l_alt=100*mean(Lr{2}(:,2:4),2);

u_0=100*mean(Ur{1}(:,2:4),2);
u_alt=100*mean(Ur{2}(:,2:4),2);


figure, %set(0,'defaulttextinterpreter','tex')
subplot(311), 
bar(1:length(nber),-1+max(0,5*nber),1,'EdgeColor',[.7,.7,.7],'FaceColor',[.7,.7,.7],'LineStyle','none','Clipping','on'),xlim([1 length(nber)])
h1=gca;
set(h1,'YAxisLocation','right','Color','white','XTickLabel',[]);
set(h1,'Fontsize',8)
h2=axes('Position',get(h1,'Position'));
set(h2,'Fontsize',8)
plot(hpfilter(l_0,5),'LineWidth',1);
hold on, plot(hpfilter(l_alt,5),'LineWidth',2,'Color',[1 0 0],'LineStyle','-');
set(h2,'YAxisLocation','left','Color','none')
ylim(h1,[2 3]), set(h1,'Yticklabel',[]), set(h1,'YTick',[],'XTick',[])
ylabel('ppt')
ylim(h2,[55 80])
set(gca','Xticklabel',num2str((1980:10:2015)'))
set(gca,'Xtick',12*4+1:12*10:length(u_0)), xlim([1 length(u_0)]),
set(h2,'XLim',get(h1,'XLim'),'Layer','top')
legend('boxoff')
h1 = legend('$LFP$','$\widehat{LFP}$','Location','Best');
set(h1,'Interpreter','latex','FontName','Arial','FontSize',7)
legend('boxoff')
title('Prime-age female')

subplot(312)
bar(1:length(nber),-1+max(0,5*nber),1,'EdgeColor',[.7,.7,.7],'FaceColor',[.7,.7,.7],'LineStyle','none','Clipping','on'),xlim([1 length(nber)])
h1=gca;
set(h1,'YAxisLocation','right','Color','white','XTickLabel',[]);
set(h1,'Fontsize',8)
h2=axes('Position',get(h1,'Position'));
set(h2,'Fontsize',8)
plot(hpfilter(u_0,5),'LineWidth',1);
hold on, plot(hpfilter(u_alt,5),'LineWidth',2,'Color',[1 0 0],'LineStyle','-');
set(h2,'YAxisLocation','left','Color','none')
ylim(h1,[2 3]), set(h1,'Yticklabel',[]), set(h1,'YTick',[],'XTick',[])
ylabel('ppt')
ylim(h2,[3 9])
set(gca','Xticklabel',num2str((1980:10:2015)'))
set(gca,'Xtick',12*4+1:12*10:length(u_0)), xlim([1 length(u_0)]),
set(h2,'XLim',get(h1,'XLim'),'Layer','top')
legend('boxoff')
h1 = legend('$U$','$\widehat{U}$','Location','Best');
set(h1,'Interpreter','latex','FontName','Arial','FontSize',7)
legend('boxoff')

diff=hpfilter(u_0-u_alt,10^6);

subplot(313), plot(diff,'Linewidth',2)
hold on, plot(0*diff,'--black')
ylabel('ppt','FontSize',8), ylim([-1 1.75])
set(gca,'FontSize',8)
h3 = legend('$U-\widehat{U}$','Location','NorthEast');
set(h3,'Interpreter','latex','FontName','Arial','FontSize',7)
set(gca','Xticklabel',num2str((1980:10:2015)'))
set(gca,'Xtick',12*4+1:12*10:length(u_0)), xlim([1 length(u_0)]),
legend('boxoff')

%Data for online appendix
trend_w=diff;